home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_03
/
1003074a
< prev
next >
Wrap
Text File
|
1992-01-11
|
709b
|
33 lines
Listing 7
//
// rational.h
//
#include <stdio.h>
class rational
{
public:
rational() { }
rational(long n) : num(n), denom(1) { }
rational(long n, long d) : num(n), denom(d) { }
rational &operator+=(rational r);
rational &operator-=(rational r);
rational &operator*=(rational r);
rational &operator/=(rational r);
rational operator+() { return *this; }
rational operator-();
rational operator++() { return *this += 1; }
rational operator--() { return *this -= 1; }
rational operator++(int); // postfix ++
rational operator--(int); // postfix --
void put(FILE *);
private:
long num, denom;
void simplify();
};
// ... the rest of rational.h as in Listing 5